<?php
namespace Admin\Controller;
use Think\Controller;
class AdvsController extends Controller {
    //首页查询数据方法
    public function index(){
        $advs = D('advs');
        $list = $advs->advs_sec();
        $this->assign('list',$list);
        $this->display();
    }
    //展示添加
    public function add_advs(){
        $this->display();
    }
    //添加操作
    public function add_ad(){
        $advs = D('advs');
        $res = $advs->add_advs();
        // dump($res);
        // exit;
        if($res){
            $this->success('添加成功');
        }else{
            $this->error('添加失败,请重新输入');
        }
        
    }
    //显示修改页
    public function edit_advs(){
        $advs = D('advs');
        $list = $advs->find_advs();
        // dump($list);
        $this->assign('list',$list);
        $this->display();
    }
    //执行修改操作
    public function edit_ad(){
        $advs = D('advs');
        $res = $advs->advs_edit();
        if($res){
            $this->success('修改成功');
        }else{
            $this->error('修改失败，请重新输入');
        }
    }
    //删除
    public function advs_del(){
        $advs = D('advs');
        $res = $advs->del_advs();
        if($res){
            echo '删除成功';
        }else{
            echo '删除失败';
        }
    }
}